package com.bw.day03.catexq

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.bw.base.net.entity.GoodsEntity
import com.bw.base.net.entity.Res
import com.bw.base.net.mvvm.BaseViewModel
import com.bw.day03.utlis.SingleLiveData
import kotlinx.coroutines.launch
import retrofit2.http.Query

class CateXqViewModel: BaseViewModel() {
    val cateXqSuccess = SingleLiveData<Res<GoodsEntity>>()
    val cateXqFail = SingleLiveData<String>()
    fun cateXq(cid: Int,keyword: String,limit: Int,news: Boolean,page: Int,priceOrder: String,salesOrder: String){
        viewModelScope.launch {
            try {
                cateXqSuccess.postValue(apiService.cateXq(cid,keyword,limit,news,page,priceOrder,salesOrder))
            }catch (e:Exception){
                cateXqFail.postValue(e.message.toString())
            }
        }
    }
}